package servlet;

import com.example.koki.bean.NewsBean;
import com.example.koki.util.HelloServlet;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.HashMap;
import java.util.Properties;
    @WebServlet("/newsAdd.jsp")
public class NewsAddservlet extends HelloServlet {
    @Override
    protected  viod doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        String name = req.getParameter("NewsTitle");
        String nameContent = req.getParameter("NewsContent");
        NewsBean newsBean = new NewsBean();
        newsBean.setNewsTime(newsTitle);
        newsBean.setNewsContent(nameContent);
        newsDao newDao =new NewsDao();
        newDao.add(newsBean);
        req.getRequestDispatcher("new.jps").forward(req.resp);
    }
}
